﻿using System;
using Orchard.ContentManagement.MetaData;
using Orchard.DisplayManagement;
using Orchard.Environment.Extensions;
using Orchard.Forms.Services;
using Orchard.Localization;

namespace Vitus.Localization.Projections
{
    [OrchardFeature("Vitus.CultureProjectionFilters")]
    public class SpecificCultureFilterForms : IFormProvider
    {
        private readonly IContentDefinitionManager _contentDefinitionManager;
        protected dynamic Shape { get; set; }
        public Localizer T { get; set; }

        public SpecificCultureFilterForms(
            IShapeFactory shapeFactory,
            IContentDefinitionManager contentDefinitionManager)
        {
            _contentDefinitionManager = contentDefinitionManager;
            Shape = shapeFactory;
            T = NullLocalizer.Instance;
        }

        public void Describe(DescribeContext context)
        {
            Func<IShapeFactory, object> form =
                shape =>
                {
                    var f = Shape.Form(
                        Id: "SpecificCulture",
                        _Parts: Shape.Textbox(
                            Id: "culture", Name: "Culture",
                            Title: T("Culture"),
                            Description: T("Enter the culture."),
                            Size: 5
                            )
                        );

                    return f;
                };

            context.Form("SpecificCultureFilter", form);

        }
    }
}